package com.cloudsigns.factorymanager2.project.presenter;

import android.os.Handler;

import com.cloudsigns.factorymanager2.project.iview.IProductOrderSendView;
import com.cloudsigns.factorymanager2.project.model.IProductOrderSendModel;
import com.cloudsigns.factorymanager2.project.model.ProductOrderSendModel;

public class ProductOrderSendPresenter {
    private IProductOrderSendView view;
    private IProductOrderSendModel model;
    private Handler mHandler = new Handler();

    public ProductOrderSendPresenter(IProductOrderSendView iView) {
        this.view = iView;
        this.model = new ProductOrderSendModel();
    }

    public void productOrderSend() {
        model.sendEngineeringOrder(view.getOrderId(), view.getReceiveAccountId(), new ProductOrderSendModel.OnSendProductOrderListener() {
            @Override
            public void successed() {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.sendSuccess();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.sendFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });
    }
}
